package com.sam.im.heiqun.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;

import com.nanchen.compresshelper.CompressHelper;

import java.io.File;

/**
 * Created by Administrator on 2018/11/28.
 */

public  class ImageCompressUtil {

    public  static File changeImage(File oldFile,Context context){
        File newFile = new CompressHelper.Builder(context)
                .setMaxWidth(820)  // 默认最大宽度为720
                .setMaxHeight(1060) // 默认最大高度为960
                .setQuality(100)    // 默认压缩质量为80
                .setCompressFormat(Bitmap.CompressFormat.JPEG) // 设置默认压缩为jpg格式
                .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(
                        Environment.DIRECTORY_PICTURES).getAbsolutePath())
                .build()
                .compressToFile(oldFile);
               return newFile;
    }
}
